package org.oaix.proxy;

import net.sf.cglib.proxy.Enhancer;
import org.oaix.proxy.cg.PersonInterceptor;

public class ProxyTest {

	public static void main(String[] args) {
		cgLibTest(Person.class);
	}


	private static void cgLibTest(Class<Person> personClass){

		Enhancer enhancer=new Enhancer();
		enhancer.setClassLoader(personClass.getClassLoader());
		enhancer.setSuperclass(personClass);
		enhancer.setCallback(new PersonInterceptor());
		Person personProxy=(Person) enhancer.create();
		System.out.println(personProxy.add(1));
	}
}
